package com.situ.hr4.w.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.situ.hr4.pojo.EngageResume;
import com.situ.hr4.w.service.JLGLservice;
import com.situ.hr4.w.service.LYGLservice;
import com.situ.hr4.w.service.MSGLservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

//录用管理
@Controller
public class LYGLcontroller {
    @Autowired
    LYGLservice lygl;
    @Autowired
    MSGLservice msgl;
    @Autowired
    JLGLservice jlgl;

    //录用申请
    @RequestMapping("a8")
    public String a8(Map map,
                     @RequestParam(defaultValue = "1", required = false) Integer startPage,
                     @RequestParam(defaultValue = "3", required = false) Integer PageSize) {
        int id = 4;
        PageHelper.startPage(startPage, PageSize); //使用分页插件
        List<Map> l = lygl.qc(id);
        PageInfo pageInfo = new PageInfo(l, 3); //保存分页信息
        map.put("pageInfo", pageInfo); //绑定分页信
        map.put("l", l);
        return "/page/recruit/employ/register_list.html";
    }

    //跳转到录用申请
    @RequestMapping("lysq")
    public String lysq(int id, Map map) {
        //通过id查询所有信息
        EngageResume e = jlgl.jlxxid(id);
        //查询职位
        Map zw = jlgl.zwmcid(id);
        //根据id查面试表和简历
        Map l = msgl.qc(id);
        map.put("l", l);
        map.put("e", e);
        map.put("m", zw);
        return "page/recruit/employ/register.html";
    }

    //跳转至录用申请
    @RequestMapping("Wtzlysq")
    public String Wtzlysq(EngageResume er, String s) {
        if (s.equals("申请录用")) {
            //根据id将面试状态改为待录用,修改录用描述
            er.setInterview_status(5);
            lygl.update(er);
        } else {
            er.setInterview_status(6);
            lygl.update(er);
        }
        return "redirect:a8";
    }


    //录用审批
    @RequestMapping("a9")
    public String a9(Map map,
                     @RequestParam(defaultValue = "1", required = false) Integer startPage,
                     @RequestParam(defaultValue = "3", required = false) Integer PageSize) {
        //全查待录用的
        int id = 5;
        PageHelper.startPage(startPage, PageSize); //使用分页插件
        List<Map> l = lygl.qc(id);
        PageInfo pageInfo = new PageInfo(l, 3); //保存分页信息
        map.put("pageInfo", pageInfo); //绑定分页信
        map.put("l", l);
        return "/page/recruit/employ/check_list.html";
    }

    //跳转到审批
    @RequestMapping("Wtzsp")
    public String Wtzsp(int id, Map map) {
        //通过id查询所有信息
        EngageResume e = jlgl.jlxxid(id);
        //查询职位
        Map zw = jlgl.zwmcid(id);
        //根据id查面试表和简历
        Map l = msgl.qc(id);
        map.put("l", l);
        map.put("e", e);
        map.put("m", zw);
        return "page/recruit/employ/check.html";
    }

    //跳转至录用审批
    @RequestMapping("Wtzlysp")
    public String Wtzlysp(EngageResume er, String s) {
        if (s.equals("通过")) {
            //根据id将面试状态改为已录用,修改录用描述
            er.setInterview_status(7);
            lygl.update1(er);
        } else {
            //审核未通过
            er.setInterview_status(8);
            lygl.update1(er);
        }
        return "redirect:a9";
    }


    //录用查询
    @RequestMapping("a10")
    public String a10(Map map,
                      @RequestParam(defaultValue = "1", required = false) Integer startPage,
                      @RequestParam(defaultValue = "3", required = false) Integer PageSize) {
        //全查录用的
        int id = 7;
        PageHelper.startPage(startPage, PageSize); //使用分页插件
        List<Map> l = lygl.qc(id);
        PageInfo pageInfo = new PageInfo(l, 3); //保存分页信息
        map.put("pageInfo", pageInfo); //绑定分页信
        map.put("l", l);
        return "/page/recruit/employ/list.html";
    }

    //跳转到详情
    @RequestMapping("Wcxxq")
    public String Wcxxq(int id, Map map) {
        //通过id查询所有信息
        EngageResume e = jlgl.jlxxid(id);
        //查询职位
        Map zw = jlgl.zwmcid(id);
        //根据id查面试表和简历
        Map l = msgl.qc(id);
        System.out.println(l.get("pass_checkComment"));
        map.put("l", l);
        map.put("e", e);
        map.put("m", zw);
        return "page/recruit/employ/details.html";
    }
}